package hu.jonas.allunit.model;

import org.eclipse.jdt.junit.model.ITestCaseElement;
import org.eclipse.jdt.junit.model.ITestElement.Result;

public class TestResult {

	private String projectName;
	private String className;
	private String methodName;
	private double elapsedTime;
	private TestResultOutcome outcome;

	public TestResult() {
	}
	
	public TestResult(ITestCaseElement testCaseElement) {
		className = testCaseElement.getTestClassName();
		methodName = testCaseElement.getTestMethodName();
		elapsedTime = testCaseElement.getElapsedTimeInSeconds();
		
		Result testResult = testCaseElement.getTestResult(false);
		if (testResult == Result.OK) {
			outcome = TestResultOutcome.Ok;
		} else if (testResult == Result.FAILURE) {
			outcome = TestResultOutcome.Failed;
		} else if (testResult == Result.ERROR) {
			outcome = TestResultOutcome.Crashed;
		} else {
			outcome = TestResultOutcome.Ignored;
		}
	}
	
	public double getElapsedTime() {
		return elapsedTime;
	}

	public String getProjectName() {
		return projectName;
	}

	public String getTestClassName() {
		return className;
	}

	public String getTestMethodName() {
		return methodName;
	}

	public void setElapsedTime(double testElapsedTime) {
		this.elapsedTime = testElapsedTime;
	}

	public void setProject(String projectName) {
		this.projectName = projectName;
	}

	public void setTestClassName(String testClassName) {
		this.className = testClassName;
	}

	public void setTestMethodName(String testMethodName) {
		this.methodName = testMethodName;
	}

	public void setOutcome(TestResultOutcome outcome) {
		this.outcome = outcome;
	}

	public TestResultOutcome getOutcome() {
		return outcome;
	}

}
